package com.fox.hiring.common;

import java.util.List;

/**
 * 分页模型
 * 
 * @author fox.
 * @da2016年3月8日
 */
public class PageModel<T> {

	/**
	 * 数据集
	 */
	private List<T> list;

	/**
	 * 总记录数
	 */
	private int totalRecords;

	/**
	 * 当前所在页
	 */
	private int pageNo;

	/**
	 * 每页显示多少条
	 */
	private int pageSize;

	public PageModel(List<T> list, int totalRecords, int pageNo, int pageSize) {
		super();
		this.list = list;
		this.totalRecords = totalRecords;
		this.pageNo = pageNo;
		this.pageSize = pageSize;
	}

	/**
	 * 得到总页数
	 * 
	 * @return
	 */
	public int getTotalPages() {
		return (int) Math.ceil((double) totalRecords / pageSize);
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

}
